import Abstract from '../abstract';

class Bookmark extends Abstract {
    categoryList(data: { page_size: number; page_current: number }) {
        return this.getReq({url: 'Basic.category', params: data});
    }

    CreateCategory(data: { name: string; sort?: any }) {
        return this.postReq({url: 'Basic.category', data});
    }

    UpdateCategory(data: { id: any; name: string; sort?: any }) {
        return this.postReq({url: 'Basic.category_update', data});
    }

    DelCategory(data: { id: string }) {
        return this.deleteReq({url: 'Basic.category', params: data});
    }

    CategorySelect() {
        return this.getReq({url: 'Basic.category_select'});
    }

    BookmarkList(data: {
        page_size?: number;
        page_current?: number;
        category_id?: any;
    }) {
        return this.getReq({url: 'Bookmark.bookmark', params: data});
    }

    BookmarkCreate(data: any) {
        return this.postReq({url: 'Bookmark.bookmark', data});
    }

    BookmarkUpdate(data: any) {
        return this.postReq({url: 'Bookmark.bookmark_update', data});
    }

    BookmarkDel(data: { id: number }) {
        return this.deleteReq({url: 'Bookmark.bookmark', params: data});
    }

    BookmarkUser() {
        return this.getReq({url: 'Bookmark.bookmark_user'});
    }

    BookmarkHoardTags(data: { id: number; tags?: number; hoard?: number }) {
        return this.getReq({url: 'Bookmark.bookmark_hoard_tags', params: data});
    }
}

// 单列模式返回对象
let instance;
export default (() => {
    if (instance) return instance;
    instance = new Bookmark();
    return instance;
})();
